<?php

namespace Shadon\CloudPrint\Traits;

use GuzzleHttp\Client;

/**
 * Trait HttpRequest.
 */
trait HttpRequest
{
    public function request(string $method, string $url, array $data = [])
    {
        $client = new Client();
        $response = $client->request($method, $url, ['form_params' => $data]);

        $content = (string) $response->getBody();
        $object = [];

        if ('' != $content) {
            $object = json_decode($content, true);
        }

        return $object;   
    }
}